// pages/shiping/shiping.js
const app = getApp()
Page({
  data: {
    type:'',
    weishipinglist: [{
      name:'大帅哥',
      title: '海边随拍',
      video: 'http://rmh55a34a.hd-bkt.clouddn.com/shiping/1.mp4?e=1670339580&token=02dt6g2HOOwgVjD4ixKyvU-nKrHeaO8OpW14U0p3:v1XCDrdlt49O8lzTjGYRT5PXTog=',
      src:'/shiliang/weiNingTuiJian.png'
  },
  {
    name:'大帅哥',
    title: '海边随拍',
    video: 'http://rmh55a34a.hd-bkt.clouddn.com/shiping/1.mp4?e=1670339580&token=02dt6g2HOOwgVjD4ixKyvU-nKrHeaO8OpW14U0p3:v1XCDrdlt49O8lzTjGYRT5PXTog=',
    src:'/shiliang/weiNingTuiJian.png'
},
{
  name:'大帅哥',
  title: '海边随拍',
  video: 'http://rmh55a34a.hd-bkt.clouddn.com/shiping/1.mp4?e=1670339580&token=02dt6g2HOOwgVjD4ixKyvU-nKrHeaO8OpW14U0p3:v1XCDrdlt49O8lzTjGYRT5PXTog=',
  src:'/shiliang/weiNingTuiJian.png'
},
{
  name:'大帅哥',
  title: '海边随拍',
  video: 'http://rmh55a34a.hd-bkt.clouddn.com/shiping/1.mp4?e=1670339580&token=02dt6g2HOOwgVjD4ixKyvU-nKrHeaO8OpW14U0p3:v1XCDrdlt49O8lzTjGYRT5PXTog=',
  src:'/shiliang/weiNingTuiJian.png'
}

],//视频数据
    hkindex: 0,//滑块index
  },
  onLoad: function (options) {
    console.log(options.category)
    this.setData({
      type:options.category
    })
    if(this.data.type>0){
      wx.request({
        url: 'http://localhost:80/shipingQuery/getType',
        method:"POST",
        data:{
          type:this.data.type
        },
        header:{
          'content-type': 'application/x-www-form-urlencoded'
        },
        success:res=>{
          console.log(res.data.data)
          this.setData({
            weishipinglist:res.data.data
          })
          console.log(this.data.weishipinglist)
        }
      })
    }else{
      wx.request({
        url: 'http://localhost:80/shipingQuery/getAll',
        method:"POST",
        header:{
          'content-type': 'application/x-www-form-urlencoded'
        },
        success:res=>{
          console.log(res.data.data)
          this.setData({
            weishipinglist:res.data.data
          })
        }
      })

    }
    
  },





  //动态更新当前滑块下标
  bindchange(e) {
    console.log('aaaaa')
    this.setData({
      hkindex: e.detail.current
    })
    var indx = e.detail.current;
    let videoContext = wx.createVideoContext("myvideo" + e.detail.current + "")
    let videoContexta = wx.createVideoContext("myvideo" + indx + "")  
    videoContexta.pause();
    videoContexta.seek(0);
    videoContext.play();
    let xz = this.data.weishipinglist.length- e.detail.current ;
    if (xz == 3) {
      // this.chaxunzhi();  //加载更多视频
    }
    // this.qingygnanme();
  }
})

